from dataclasses import dataclass

from django.db import models
from datetime import datetime


class Book(models.Model):
    name = models.CharField(max_length=100)
    author = models.CharField(max_length=20)
    pub_time = models.DateTimeField(auto_now_add=True)
    price = models.FloatField(default=0)

    class Meta:
        db_table = 'book_table'
        ordering = ('-pub_time','name')


class Author(models.Model):
    is_active = models.BooleanField(default=True)
    username = models.CharField(max_length=200)
    joined_at = models.DateTimeField(auto_now_add=True)
    email = models.EmailField()
    visit_count = models.IntegerField(default=0)
    profile = models.TextField(default='')
    website = models.URLField(default='')


class Tag(models.Model):
    name = models.CharField(max_length=200, db_column='tag_name')
    # 不带括号
    create_time = models.DateTimeField(default=datetime.now)
    # 0、可用  1、不可用
    # status = models.SmallIntegerField(default=0)
    class Meta:
        db_table = 'book_model' #指定表名